<!DOCTYPE html>
<html>
<head>
    {include file="public/header" /}
    <!--<link rel="stylesheet" href="/static/admin/voucher.css">-->
    <link rel="stylesheet" type="text/css" href="/static/taginput/css/normalize.css" /><!--CSS RESET-->
    <link rel="stylesheet" href="/static/taginput/src/jquery.tagsinput-revisited.css" />
    <style>
        .layui-form-select .layui-input{
            width:400px;
        }
    </style>
    <!--<link rel="stylesheet" href="/static/layuimini/lib/jq-module/zyupload/zyupload-1.0.0.min.css" media="all">-->
</head>
<body>
<div style="padding-top:10px;" class="layui-form layuimini-form">
    <input type="hidden" name="id" value="{$id}">
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">结算金额</label>
        <div class="layui-input-block">
            <input type="number" name="price" min="1" step="0.01" lay-verify="price" placeholder="请输入结款金额"  value="" class="layui-input iwidth" autocomplete="off">
        </div>
    </div>


    <div class="layui-form-item" >
        <label class="layui-form-label">结款备注</label>
        <div class="layui-input-block">
            <textarea type="text" name="desc" value="" lay-verify="explain" autocomplete="off" placeholder="结款备注" class="layui-input" aria-disabled="true" style="margin: 0px 1167.47px 0px 0px;width: 402px;height: 169px;"></textarea>
        </div>
    </div>
    <div class="layui-form-item" >
        <label class="layui-form-label">结款方式</label>

        <div class="layui-input-block" >
            <input type="radio"  name="pay_type" value="1"  lay-filter="radio"   title="微信" checked>

            <input type="radio" name="pay_type" value="2"  lay-filter="radio"  title="支付宝" >

        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script src="/static/taginput/src/jquery.tagsinput-revisited.js"></script>

<script>

    layui.use(['form','wangEditor','laydate','upload'], function () {
        var form = layui.form,
            layer = layui.layer,
            wangEditor = layui.wangEditor,
            upload = layui.upload,
            laydate=layui.laydate,
            $ = layui.$;
        // 上架开始日期
        var insShelf = laydate.render({
            elem: '#start_time'
            , min: 0
            , calendar: true
            , type: 'datetime'
            , done: function (value, date) {
                //更新结束日期的最小日期
                insUnder.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });

                //自动弹出结束日期的选择器
                //insUnder.config.elem[0].focus();
            }
        });
        //上架结束日期
        var insUnder = laydate.render({
            elem: '#end_time'
            , min: 0
            , calendar: true
            , type: 'datetime'
            , done: function (value, date) {
                //更新开始日期的最大日期
                insShelf.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });
            }
        });
        //富文本

        //监听指定开关
        form.on('switch(switchTest)', function (data) {
            if(this.checked){
                this.value=1;
            }else{
                this.value=2;
            }
        });
        //用类型判断验证
        var verify_data = {

            price: function (value) {
                if (value == ''|| value == 0) {
                    return '结款金额不能为空或者是0';
                }
            }

        }
        //自定义验证规则
        form.verify(
            verify_data
        );
        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.ajax({
                url: "/admin/supplierpayment/payment?active=ajax",
                type: 'post',
                async: true,
                data: data.field,
                dataType: 'json',
                success: function (res) {
                    if(res.status){
                        parent.layer.msg("操作成功!", {icon:1,time: 1000}, function () {
                            //重新加载父页面
                            parent.location.reload();
                        });
                        return;
                    }else{
                        layer.msg(res.msg,{icon:5,time: 1000} );

                        // layer.open({
                        //     title: '提示信息',
                        //     content: '<span style="color:red">'+res.code+':</span>'+res.msg
                        // })
                        return false
                    }

                },
                error: function(re) {

                    layer.open({
                        title: '提示信息',
                        // content: '<span style="color:red">'+re.responseJSON.errorCode+':</span>'+re.responseJSON.msg
                        content: '<span align="center" style="color:red">'+re.responseJSON.msg+'</span>'
                    })
                }
            });
            return false;
        });
    });


</script>
</body>
</html>